package com.qf.lja.servlet;

import com.qf.lja.dao.ProductDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet(urlPatterns = "/productChange")
public class ProductChangeServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //utf-8
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String p_id = req.getParameter("p_id");
        String status = req.getParameter("status");

        //修改状态
        ProductDao productDao = new ProductDao();
        productDao.updateStatus(Integer.parseInt(p_id), Integer.parseInt(status));

        resp.sendRedirect(req.getContextPath() + "/productAdmin");
    }
}
